import { getCurrentInstance } from 'vue'

export const useForwardRef = () => {
  const instance = getCurrentInstance()

  if (!instance) {
    throw new Error('useForwardRef must be called within a setup function')
  }

  const forwardRef = (ref: any) => {
    instance.exposed = ref
    instance.exposeProxy = ref
  }

  return forwardRef
}